#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class QAction;
class QLabel;
class Quebra2D;
class canvasAppl;
class acmFrame;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow();


protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void newFile();
    void open();
    bool save();
    bool saveAs();
    void about();
    void openRecentFile();
    void updateStatusBar();

    // zoom
    void zoomIn  ( );
    void zoomOut ( );
    void zoomFit ( );
    void zoomWin ( );

    // create primitives
    void createLine   ( );
    void createArc    ( );
    void createCircle ( );
    // void createPoly   ( );
    void createSpline ( );
    void createVertex ( );
    
    void setSelectMode ( );
    void setKeyboardOn ( );

    // transformations
    void copyPri   ( );
    void deletePri ( );
    void mirrorPri ( );
    void movePri   ( );
    void rotatePri ( );
    void scalePri  ( );

    // on/off 
    void viewGrid  ( );
    void viewAxis  ( );

    // attributes
    void setAttrSection     ( );
    void setAttrMaterial    ( );
    void setAttrRestriction ( );
    void setAttrConcLoad    ( );
    void setAttrDistLoad    ( );
    void setAttrCrack       ( );



private:
    void createActions();
    void createMenus();
    void createContextMenu();
    void createToolBars();
    void createStatusBar();
    void readSettings();
    void writeSettings();
    bool okToContinue();
    bool loadFile(const QString &fileName);
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName);
    void updateRecentFileActions();
    QString strippedName(const QString &fullFileName);

    void toChar (const QString qtString, char *new_string);


    //////////////////////////////////////////////////////////////////////////
    canvasAppl  *m_canvas;
    acmFrame    *m_frameModel;

    QLabel *messageLabel;
    QLabel *positionLabel;
    QStringList recentFiles;
    QString curFile;

    enum { MaxRecentFiles = 5 };
    QAction *recentFileActions[MaxRecentFiles];
    QAction *separatorAction;


    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *viewMenu;
    QMenu *femSubMenu;
    QMenu *drawMenu;
    QMenu *modelMenu;
    QMenu *analysisMenu;
    QMenu *helpMenu;

    QToolBar *fileToolBar;
    QToolBar *editToolBar;
    QToolBar *drawToolBar;
    QToolBar *viewToolBar;
    QToolBar *modelToolBar;
    QToolBar *analysisToolBar;

    // file actions
    QAction *newAction;
    QAction *openAction;
    QAction *openNfAction;
    QAction *saveAction;
    QAction *saveAsAction;
    QAction *ImportPriAction;
    QAction *exitAction;

    // edit actions
    QAction *undoAction;
    QAction *redoAction;
    QAction *copyAction;
    QAction *deleteAction;
    QAction *mirrorAction;
    QAction *moveAction;
    QAction *rotateAction;
    QAction *scaleAction;
    QAction *selectAction;
    QAction *keyAction;

    // view actions
    //////////////////////////////////////////////////////////////////////////
    QAction *wireframeAction;
    QAction *isostripAction;
    QAction *meshAction;
    QAction *nodesAction;
    QAction *nodeNumberAction;
    QAction *elemNumberAction;
    QAction *dualAction;
    QAction *gaussAction;
    QAction *boundaryAction;
    //////////////////////////////////////////////////////////////////////////
    QAction *geomAction;
    QAction *atribAction;
    QAction *redrawAction;
    QAction *fitAction;
    QAction *zoomAction;
    QAction *zoomInAction;
    QAction *zoomOutAction;
    QAction *gridAction;
    QAction *axisAction;

    // draw actions
    //////////////////////////////////////////////////////////////////////////
    QAction *lineAction;
    QAction *arcAction;
    QAction *circleAction;
    QAction *splineAction;
    QAction *vertexAction;

    // model build action
    //////////////////////////////////////////////////////////////////////////
    QAction *subdvisionAction;
    QAction *createMeshAction;
    QAction *deleteMeshAction;
    QAction *globalParamAction;
    QAction *materialAction;
    QAction *sectionAction;
    QAction *supportAction;
    QAction *concentLoadAction;
    QAction *distribLoadAction;
    QAction *asCrackAction;

    // analysis build action
    //////////////////////////////////////////////////////////////////////////
    QAction *regularFEMAction;
    QAction *adaptiveAction;
    QAction *crackPropAction;
    
    QAction *aboutAction;
    QAction *aboutQtAction;
};

#endif
